const express = require("express")
const router = express.Router()
var bodyParser = require("body-parser")

// 创建application/json 解析器
var jsonParser = bodyParser.json()

let connectDAO = require('../connect')
async function dbTrainInfo(sql,processData) {
  //processData为回调方法
  await connectDAO.queryDataBySQL(sql, processData);
}

router.get('/get_musicList',function(req,res){
    let data = []
    dbTrainInfo(`SELECT * FROM music;`,(result)=>{
        data = result
    }).then(()=>{
        res.send({code:200,msg:'ok',data})
    }).
    catch((err)=>{
        console.log(err);
        res.send({code:201,msg:'fail'})
    })
})


module.exports = router;